<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'showVoteMessage.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

<script type="text/javascript">
	function validate(){
		var optionContent = document.getElementsByName("optionContent");
		var number=0;
		for(var i =0;i<optionContent.length;i++){
			if(optionContent[i].checked){
				num++;
			}
		}
		if(number==0){
			alert("选项必须选择!");
			return false
		}
		
		return true;
	}
</script>
</head>

<body>
	<%
		String qName = (String) session.getAttribute("qName");
		int num = (Integer) request.getAttribute("optionNum");
		List<String> list = (List<String>) request
				.getAttribute("optionContents");
	%>

	<h1>
		用户：<%=session.getAttribute("username")%></h1>
	<form action="DoVoteServlet" onsubmit="return validate()">
		问题：<%=qName%><br> 选项：<%
		for (int i = 0; i < list.size(); i++) {
	%>
		<%=list.get(i)%>:<input type="radio" name="optionContent"
			value="<%=list.get(i)%>">
		<%
			}
		%>
		<br> <input type="submit" value="提交" "/>
	</form>
</body>
</html>
